﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.StaffIndexViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Danh sách nhân sự
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
	Danh sách nhân sự
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
	<%= Html.Toolbar("Thêm mới", "/Staff/Create", "new") %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%if(ViewData["MessageInfo"]==null){ %>
	<form action="/Staff" method="post" name="adminForm">
		<table width="100%">
			<tr>
				<td align="left"><%=Html.TextBox("Name", Model.FilterName)%><input type="submit" value="Lọc" /><input type="reset" value="Thiết lập lại" /></td>
				<td align="right"><%=Html.DropDownList("OrgnizationID", new SelectList(Model.Organizations, "ID", "Name", Model.FilterOrganizationID).ToList(), "-- Chọn đơn vị --", new { onchange = "document.adminForm.submit();", style="width:250px;" })%><%=Html.DropDownList("ProfessionID", new SelectList(Model.Professions, "ID", "Name", Model.FilterProfessionID).ToList(), "-- Chọn nghề nghiệp --", new { onchange = "document.adminForm.submit();" })%></td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
			<tr>
				<th width="10" align="right">
					STT
				</th>
				<th width="30"></th>
				<th width="30"></th>
				<th>
					<%= Html.Sort("Họ tên", "Name", Model.OrderDirection, Model.OrderColumn)%>
				</th>
				<th>
					Nghề nghiệp
				</th>
				<th>
					Đơn vị
				</th>
				<th>
					<%= Html.Sort("ID", "ID", Model.OrderDirection, Model.OrderColumn)%>
				</th>
			</tr>
		<% 
			int i = 0;
            foreach (var item in Model.Staffs)
            {
				i++;
		%>		
			<tr>
				<td align="right">
					<%= i.ToString() %>
				</td>
				<td align="center">
					<%= Html.ActionImage("Sửa", "icon-24-edit.png", "Staff", "Edit", new Dictionary<string, object>(){{ "id", item.ID}})%>
				</td>
				 <td align="center">
					<%= Html.ActionImage("Xóa", "icon-24-delete.png", "Staff", "Delete", new Dictionary<string, object>() { { "id", item.ID } })%>
				</td>
				<td>
					<%= Html.ActionLink(item.Name, "Details", new { id = item.ID })%>
				</td>
				<td>
					<%= item.ProfessionID != null ? Html.Encode(item.Profession.Name) : "" %>
				</td>
				<td>
					<%= Html.Encode(item.Organization.Name) %>
				</td>
				<td>
					<%= Html.Encode(item.ID) %>
				</td>
			</tr>
	    
		<% } %>

		</table>
		<table width="100%">
			<tr>
				<td align="center">
					<div class="pager">
						<%= Html.Pager(Model.Staffs.PageSize, Model.Staffs.PageNumber, Model.Staffs.TotalItemCount)%>
					</div>
				</td>
			</tr>
		</table>

		<%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
	</form>
<% } %>
</asp:Content>

